Materials for the AFEC-X 2020::XTBG. An introduction for modeling autocorrelaition using R.
Course materials for 2020-11-2 AFEC at XTBG.
install.packages("spdep")
library(tidyverse)
library(spdep)
2D
Let’s condier maps with some enviromental variables (e.g., soil N, soil moisture…).
Soil N (z0) can be uniformly distributed.
Soil N (z) can show aggreated patterns.
ggplot(dat, aes(x = x, y = y, fill = hab)) +
geom_raster()
dat2 <- dat %>%
# mutate(hab_dummy = ifelse(hab == "valley", 0, 1)) %>%
mutate(trait = rnorm(nrow(.), mu, 0.3)) # based on z
dat2 %>%
ggplot(., aes(x = hab, y = trait, col = hab)) +
geom_violin() +
geom_jitter(width = 0.2)
\[ Y = X \beta + \rho W (Y - X \beta) + \epsilon \]
Placeholder
Placeholder
Placeholder